

package com.googlecode.flac4j.format.frame.sub;


import com.googlecode.flac4j.format.frame.Frame;
import com.googlecode.flac4j.format.frame.Header;

import com.googlecode.jinahya.util.BitAccessible;

import javax.xml.bind.annotation.XmlTransient;


/**
 *
 * @author Jin Kwon <jinahya at gmail.com>
 */
public abstract class SubData implements BitAccessible {


    // ------------------------------------------------------------ subFrameType
    /**
     * Returns the type of this SubData.
     *
     * @return type of this SubData.
     */
    public abstract int getSubFrameType();


    /**
     * 
     * @param subFrameType
     */
    public abstract void setSubFrameType(int subFrameType);


    // --------------------------------------------------------- parent Subframe
    /**
     * Returns parent SubFrame of this SubData.
     *
     * @return parent SubFrame
     */
    public final SubFrame getSubFrame() {
        return subFrame;
    }


    /**
     * Sets the parent SubFrame of this SubData.
     *
     * @param subFrame parent SubFrame
     */
    public final void setSubFrame(final SubFrame subFrame) {

        if (subFrame == null) {
            throw new NullPointerException("null subFrame");
        }

        this.subFrame = subFrame;
    }


    /**
     * Returns the Frame contains this SubData.
     *
     * @return the Frame
     */
    protected final Frame getFrame() {
        return subFrame.getFrame();
    }


    /**
     * Returns the Frame's Header.
     *
     * @return frame header
     */
    protected final Header getFrameHeader() {
        return getFrame().getHeader();
    }


    /**
     * Returns the header of this data.
     *
     * @return header
     */
    protected final SubHeader getSubFrameHeader() {
        return subFrame.getSubHeader();
    }


    /** parent SubFrame. */
    @XmlTransient
    protected SubFrame subFrame;


}

